using IQIGame.Onigao.Game;
using System.Collections.Generic;

namespace IQIGame.Onigao.GamePlay
{
    public static class TViewEntityExtension
    {
        public static void FilterAcceptableQuests(this TViewEntity entity, List<int> results)
        {
            var allQuests = entity.offeredQuests;
            if (allQuests != null)
            {
                foreach (int cid in allQuests)
                {
                    if (QuestModule.Instance.IsAcceptable(cid, entity))
                    {
                        results.Add(cid);
                    }
                }
            }
        }

        public static bool IsOfferingQuest(this TViewEntity entity)
        {
            List<int> results = ListPool<int>.Get();
            entity.FilterAcceptableQuests(results);
            bool hasQuests = results.Count > 0;
            ListPool<int>.Put(results);
            return hasQuests;
        }
    }
}
